package misc

//import scala.util.parsing.combinator._
import lexpar.JavaTokenParsers

object ArithExpr extends JavaTokenParsers {
  literal("+", "-", "*", "/", "(", ")")
  
  def expr: Parser[Any] = term ~ rep("+" ~ term | "-" ~ term)
  def term: Parser[Any] = factor ~ rep("*" ~ factor | "/" ~ factor)
  def factor: Parser[Any] = (wholeNumber | decimalNumber | floatingPointNumber) | "(" ~ expr ~ ")"
  
  def main(args: Array[String]) {
    println(parseAll(expr, "(3 + 44.39) * 5 - 6e-10"))
  }
}